<?php
$this->set('title_for_layout','GDG Poland - Spotkania GDG w Polsce');
?><div class="events-index">
    <h1><?= ($futureEvents) ? __('Najbliższe spotkania') : __('Minione spotkania') ?></h1>
<?php
if(empty($events) && empty($gplusEvents)){ ?>
    <div class="no-events-info">
        <span class="no-events-wrapper">
            <?=__('Aktualnie brak jest zaplanowanych spotkań. Sprawdź ponownie później :)')?>
        </span>
    </div>
<?php } else {
if(!empty($gplusEvents)){
    
    ?>
    <h2 class="gp-title">Eventy GDG na Google+</h2>
    <div class="gplus-events-list">
        <div class="gplus-events-list-wrapper">
    <?php
    foreach($gplusEvents as $event){
        $chapterImage = null;
        if(!empty($event['Chapter']['image'])){
            $chapterImage = $event['Chapter']['image'];
        } 
        $chapterUrl = "/";
        if(empty($event['Chapter']['url'])){
            if(empty($event['Chapter']['slug'])){
                $chapterUrl = null;
            } else {
                $chapterUrl = $this->Html->url(array('controller'=>'chapters','action'=>'view','slug'=>$event['Chapter']['slug']));
            }
        } else {
            $chapterUrl = $event['Chapter']['url'];
        }
        ?><div class="gp-event"><div class="gp-event-wrapper">
            <div class="gpe-title"><?=$event['Gevent']['name']?></div>
            <div class="gpe-desc">
                <div class="gpe-desc-wrapper">
                    <?=$event['Gevent']['desc']?>
                </div>
                <div class="gp-action">
                    <a class="gp-scroll" data-txt="rozwiń|zwiń" href="https://plus.google.com/events/<?=$event['Gevent']['eventid']?>">rozwiń</a>
                </div>
            </div>
            <div class="gp-chapterinfo">
                <?php if($chapterUrl){ ?>
                <a href="<?= $chapterUrl ?>" title="Idź do wizytówki <?=$event['Chapter']['name']?>" class="index-chapter-link" rel="nofollow">
                <?php if($chapterImage){ echo $this->Html->image('/static/gdglogo/'.$chapterImage,array('class'=>'chapter', 'alt'=> ' Logo ' . $event['Chapter']['name'])); } else { echo $event['Chapter']['name']; } ?>
                </a>
                <?php } ?>
                <a target="_blank" href="<?=$event['Gevent']['eventurl']?>" class="gbutton green">Zobacz więcej</a>
            </div>
        </div></div><?php
    }
    ?></div></div><?php
}
?>
    <h2 class="gp-title">Pozostałe spotkania GDG</h2>
    <div class="regular-events">
<?php   
foreach($events as $event){
    $eventUrl = $this->Html->url(array('controller'=>'events','action'=>'view','slug'=>$event['Event']['slug']));
    $chapterImage = null;
    if(!empty($event['Chapter']['image'])){
        $chapterImage = $event['Chapter']['image'];
    } 
    $chapterUrl = "/";
    if(empty($event['Chapter']['url'])){
        $chapterUrl = $this->Html->url(array('controller'=>'chapters','action'=>'view','slug'=>$event['Chapter']['slug']));
    } else {
        $chapterUrl = $event['Chapter']['url'];
    }
$accepting = true;
if($event['Event']['accepting'] == '0'){
    $accepting = false;
}
?>
<div class="event">
    <div class="event-wrapper">
    <a class="right gbutton blue share-button-intent hidden" data-url="<?=$this->Html->url($eventUrl,true)?>" href="#">Udostępnij</a>
    <?php if($accepting && $futureEvents): ?>
    <a class="gbutton blue right hidden" data-eventid="<?=$event['Event']['id']?>" href="<?=$eventUrl?>">Chcę tam być</a>
    <?php endif; ?>
    <div class="name">
        <a href="<?=$eventUrl?>">
        <?=$event['Event']['name']?>
        </a>
    </div>
    <div class="clearfix"></div>
    <a href="<?= $chapterUrl ?>" title="Idź do wizytówki <?=$event['Chapter']['name']?>" class="index-chapter-link" rel="nofollow">
    <?php if($chapterImage){ echo $this->Html->image('/static/gdglogo/'.$chapterImage,array('class'=>'chapter', 'alt'=> ' Logo ' . $event['Chapter']['name'])); } else { echo $event['Chapter']['name']; } ?>
    </a>
    <div class="date"><?=$this->Timepl->niceShort($event['Event']['startdate'])?></div>
    </div>
</div>
<?php } ?>
</div>
<?php } ?>
    <?php if($futureEvents): ?>
    <a class="right button past-events-load" data-page="1" href="<?=$this->Html->url(array('controller'=>'events','action'=>'index','since'=>'now'),true)?>">Zobacz zakończone spotkania</a>
    <?php endif; ?>
    <div class="clearfix"></div>
</div>
